package com.tingyun.sign.utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.util.Assert;

import com.tingyun.sign.core.entity.ScUManagerBean;

public class BaseController {
	public static final String USER = "currentUser";

	protected static final String ERROR_MSG_KEY = "errorMsg";  

    //获取保存在Session中的用户对象  
    protected ScUManagerBean getSessionUser(HttpSession session) { 
    	return (ScUManagerBean) session.getAttribute(USER);
    }  
     
     //将用户对象保存到Session中  
    protected void setSessionUser(HttpSession session,ScUManagerBean bean) {  
    	session.setAttribute(USER, bean);  
    	session.setMaxInactiveInterval(20*60);//20min
    }  
      
    //获取基于应用程序的url绝对路径  
    public final String getAppBaseUrl(HttpServletRequest request, String url) {  
        Assert.hasLength(url, "url不能为空");  
        Assert.isTrue(url.startsWith("/"), "必须以/打头");  
        return request.getContextPath() + url;  
    }  
}
